/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bynightBusinessLogic;

import bynightClasses.Cliente;
import bynightClasses.Locale;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;

/**
 *
 * @author Ivan
 */
@Stateless
@LocalBean
public class Gestore {
    @EJB
    private EventoFacade eventoFacade;
    @EJB
    private LocaleFacade localeFacade;
    @EJB
    private PrenotazioneFacade prenotazioneFacade;
    @EJB
    private RecensioneFacade recensioneFacade;
    @EJB
    private ClienteFacade clienteFacade;

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

    public void registraLocale(String nome, 
                                    String proprietario, 
                                    String indirizzo, 
                                    String telefono, 
                                    String piva, 
                                    String numposti, 
                                    String orario, 
                                    String email,
                                    String username,
                                    String pass) 
    {
        Locale pub=new Locale();
        pub.setEmail(email);
        pub.setIndirizzo(indirizzo);
        pub.setNome(nome);
        pub.setNumPosti(Integer.parseInt(numposti));
        pub.setPartitaIva(piva);
        pub.setOrario(orario);
        pub.setProprietario(proprietario);
        pub.setTelefono(telefono);
        pub.setUsername(username);
        pub.setPassword(pass);
        pub.setOpenID(null);
        localeFacade.create(pub);
    }

    public void registraCliente(String nome, 
                                String cognome, 
                                String indirizzo, 
                                String telefono, 
                                String dataNascita, 
                                String email, 
                                String username, 
                                String pass) {
        Cliente c = new Cliente();
        c.setNome(nome);
        c.setCognome(cognome);
        c.setIndirizzo(indirizzo);
        c.setTelefono(telefono);
        c.setDataNascita(dataNascita);
        c.setEmail(email);
        c.setUsername(username);
        c.setPassword(pass);
        c.setOpenID(null);
        clienteFacade.create(c);
    }

    public List<Locale> cerca(String cerca) 
    {
        return localeFacade.search(cerca);
    }
    
    
}
